<?php
declare (strict_types = 1);

namespace app\tools;

use PhpOffice\PhpSpreadsheet\IOFactory;

class ExcelImportTool
{
    protected $sheet;

    public function __construct($filename)
    {
        $spreadsheet = IOFactory::load($filename);
        $this->sheet = $spreadsheet->getActiveSheet();
    }

    /**
     * 获取单个工作表返回数据
     *
     * @return array
     */
    public function getSheetData()
    {
        return $this->sheet->toArray('', false, false, true);
    }
}
